#!/usr/bin/perl

use strict;
use warnings;

my $filename="/home/ktang/projects/genome_stats/sordaria/feature_alignments/gb_sordaria.intron.stats.dat";
my $FNAFILE;

open ($FNAFILE, '<', $filename)
    or die "Cannot open:$filename:$!";

my $f1="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i1.stats.dat";
my $f2="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i2.stats.dat";
my $f3="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i3.stats.dat";
my $f4="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i4.stats.dat";
my $f5="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i5.stats.dat";
my $f6="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i6.stats.dat";
my $f7="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i7.stats.dat";
my $f8="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i8.stats.dat";
my $f9="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i9.stats.dat";
my $f10="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i10.stats.dat";
my $f11="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i11.stats.dat";
my $f12="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i12.stats.dat";
my $f13="/home/ktang/projects/genome_stats/sordaria/feature_alignments/intron/gb_sordaria.i13.stats.dat";


my $F1;
my $F2;
my $F3;
my $F4;
my $F5;
my $F6;
my $F7;
my $F8;
my $F9;
my $F10;
my $F11;
my $F12;
my $F13;


open ($F1 , '>', $f1)
    or die "Cannot open:$!";

open ($F2 , '>', $f2)
    or die "Cannot open:$!";
open ($F3 , '>', $f3)
    or die "Cannot open:$!";
open ($F4 , '>', $f4)
    or die "Cannot open:$!";
open ($F5 , '>', $f5)
    or die "Cannot open:$!";
open ($F6 , '>', $f6)
    or die "Cannot open:$!";
open ($F7 , '>', $f7)
    or die "Cannot open:$!";
open ($F8 , '>', $f8)
    or die "Cannot open:$!";
open ($F9 , '>', $f9)
    or die "Cannot open:$!";
open ($F10 , '>', $f10)
    or die "Cannot open:$!";
open ($F11 , '>', $f11)
    or die "Cannot open:$!";
open ($F12 , '>', $f12)
    or die "Cannot open:$!";
open ($F13 , '>', $f13)
    or die "Cannot open:$!";

printf $F1 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F2 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F3 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F4 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F5 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F6 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F7 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F8 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F9 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F10 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F11 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F12 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";
printf $F13 "FEATURE\tALN_LENGTH\tSEQ_LEN\tALL_ID\tNC_JCUC\tPW_ID\tNCRA_D\tNTET_D\tNDIS_D\n";


print "running  ";

while(my $line = <$FNAFILE>)
{
   
    chomp $line;
    if ($line =~ /\.i(\d+)/ )
    {
      if ($1 == 1)
      {
	  printf $F1 "$line \n";
      }

if ($1 == 2)
      {
	  printf $F2 "$line \n";
      }

if ($1 == 3)
      {
	  printf $F3 "$line \n";
      }
if ($1 == 4)
      {
	  printf $F4 "$line \n";
      }
if ($1 == 5)
      {
	  printf $F5 "$line \n";
      }
if ($1 == 6)
      {
	  printf $F6 "$line \n";
      }
if ($1 == 7)
      {
	  printf $F7 "$line \n";
      }
if ($1 == 8)
      {
	  printf $F8 "$line \n";
      }
if ($1 == 9)
      {
	  printf $F9 "$line \n";
      }
if ($1 == 10)
      {
	  printf $F10 "$line \n";
      }
if ($1 == 11)
      {
	  printf $F11 "$line \n";
      }
if ($1 == 12)
      {
	  printf $F12 "$line \n";
      }
if ($1 == 13)
      {
	  printf $F13 "$line \n";
      }

    }
}

close ($FNAFILE);
close ($F1);
close ($F2);
close ($F3);
close ($F4);
close ($F5);
close ($F6);
close ($F7);
close ($F8);
close ($F9);
close ($F10);
close ($F11);
close ($F12);
close ($F13);

